package org.shj.book2.chapter09.improve;

import java.util.concurrent.Future;


public class Main {

	public static void main(String[] args){
		System.out.println("main begin");
		Host host = new Host();
		Future<String> data1 = host.request(10, 'A');
		Future<String> data2 = host.request(20, 'B');
		Future<String> data3 = host.request(30, 'C');
		
		//System.out.println("main otherJob Begin");
		
		/*try{
			Thread.sleep(2000);
		}catch(InterruptedException e){
			
		}*/
		
		System.out.println("main is waiting result");
		
		try{
			System.out.println("data1 = " + data1.get());
			System.out.println("data2 = " + data2.get());
			System.out.println("data3 = " + data3.get());
		}catch(Exception e){
			System.out.println("get future data failed.");
		}
		
		host.shutdown();
		System.out.println("main END");
		
	}
}
